
using System.Globalization;
using System.Text;
using System.Security.Cryptography;
namespace server.Services;

public interface IEncryptService
{
    public string Encrypt(string raw);
    // public string Decrpt(string secret);
}

// public interface IDecryptService{
//     public string Decrypt(string secret, int salt){

//     }
// }

public class MD5Encrypt: IEncryptService
{
    private MD5 md5;
    public MD5Encrypt()
    {
        md5 = MD5.Create();
    }
    public string Encrypt(string raw)
    {
        var buffer = Encoding.UTF8.GetBytes(raw);
        var md5_buffer = md5.ComputeHash(buffer);
        var chars = md5_buffer.Select(b => b.ToString("x"));
        return string.Join("", chars);
    }
}

